﻿using System;
using System.Collections.Generic;
using System.Windows.Controls;
using MVVM_CAD.Algorithms;
using MVVM_CAD.Common;
using MVVM_CAD.Model;

namespace MVVM_CAD.Strategy
{
    public class PolyLineToolStrategy : StrategyBase
    {
        public PolyLineToolStrategy(IFigure figure) : base(figure)
        { }

        public override IFigure PerformMouseLeftClicDownEvent(Canvas canvas, IPoint point, IEnumerable<IFigure> figures)
        {
            ClickCount++;
            point.IsVertex = true;
            if (ClickCount <= 1)
            {
                ValidateFigureIsNew<PolyLine>();
                Figure.PointsCollection.Add(point);
                return Figure;
            }
            var lineRepresentation = BressenhamLine.GetLineRepresentation(Figure.FinalPoint, point);
            DrawFigureInCanvas(canvas, lineRepresentation);
            return Figure;
        }

        public override IFigure PerformMouseLeftClicUpEvent(Canvas canvas, IPoint point, IEnumerable<IFigure> figures)
        {
            throw new NotImplementedException();
        }

        public override IFigure PerformMouseRightClicDownEvent(Canvas canvas, IPoint point, IEnumerable<IFigure> figures)
        {
            if (ClickCount < 1)
            {
                return Figure;
            }
            var lineRepresentation = BressenhamLine.GetLineRepresentation(Figure.FinalPoint, point);
            DrawFigureInCanvas(canvas, lineRepresentation);
            return CloseFigureDrawing();
        }

        public override IFigure PerformMouseMoveEvent(IPoint point, IEnumerable<IFigure> figures)
        {
            throw new NotImplementedException();
        }

        public override IFigure PerformMouseMoveEvent(DrawingCanvas Canvas, CustomPoint point)
        {
            throw new NotImplementedException();
        }
    }
}
